import sys
from tkinter import *


class HelloClass:
    def __init__(self):
        widget = Button(None, text="按钮", command=self.quit)
        widget.pack()

    def quit(self):
        print("退出")
        sys.exit()


HelloClass()
mainloop()
